package com.han.entity;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

public class ResultBean<T> implements Serializable {
    private static final long serialVersionUID = 2L;

    /**
     * true  成功  false  失败
     */
    @ApiModelProperty("true  成功  false  失败")
    private boolean result;
    /**
     * 返回消息
     */
    @ApiModelProperty("返回消息")
    private String message;
    /**
     * 返回的日志信息
     */
    @ApiModelProperty("返回的日志信息")
    private String logInfo;
    /**
     * 返回的具体数据
     */
    @ApiModelProperty("返回的具体数据")
    private Object data;

    /**
     * 符合规范的数据总数
     */
    @ApiModelProperty("符合规范的数据总数")
    private Integer total;


    public static ResultBean error(String message) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(false);
        resultBean.setMessage(message);
        return resultBean;
    }

    public static ResultBean error(String message, String logInfo) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(false);
        resultBean.setMessage(message);
        resultBean.setLogInfo(logInfo);
        return resultBean;
    }

    public static ResultBean error(String message, Object object) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(false);
        resultBean.setMessage(message);
        resultBean.setData(object);
        return resultBean;
    }

    public static ResultBean error(String message, Object object, String logInfo) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(false);
        resultBean.setMessage(message);
        resultBean.setData(object);
        resultBean.setLogInfo(logInfo);
        return resultBean;
    }

    public static ResultBean success(String message) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(true);
        resultBean.setMessage(message);
        return resultBean;
    }


    public static ResultBean success(String message, Object object) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(true);
        resultBean.setMessage(message);
        resultBean.setData(object);
        return resultBean;
    }

    public static ResultBean success(String message, Object object, Integer total) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(true);
        resultBean.setMessage(message);
        resultBean.setData(object);
        resultBean.setTotal(total);
        return resultBean;
    }

    public static ResultBean success(String message, Object object, Integer total, String logInfo) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(true);
        resultBean.setMessage(message);
        resultBean.setData(object);
        resultBean.setTotal(total);
        resultBean.setLogInfo(logInfo);
        return resultBean;
    }

    public static ResultBean success(String message, Object object, String logInfo) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(true);
        resultBean.setMessage(message);
        resultBean.setData(object);
        resultBean.setLogInfo(logInfo);
        return resultBean;
    }

    public static ResultBean success(String message, String logInfo) {
        ResultBean resultBean = new ResultBean();
        resultBean.setResult(true);
        resultBean.setMessage(message);
        resultBean.setLogInfo(logInfo);
        return resultBean;
    }

    public boolean getResult() {
        return result;
    }

    public void setResult(boolean result) {
        this.result = result;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getLogInfo() {
        return logInfo;
    }

    public void setLogInfo(String logInfo) {
        this.logInfo = logInfo;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "ResultBean{" +
                "result=" + result +
                ", message='" + message + '\'' +
                ", logInfo='" + logInfo + '\'' +
                ", data=" + data +
                ", total=" + total +
                '}';
    }
}



